<%@ page language="java" contentType="image/png" pageEncoding="UTF-8"%>
<%@ page import="org.patchca.utils.encoder.EncoderHelper"%>
<%@ page import="com.mstanford.movie.utils.CaptchaService"%>
<%
	response.reset();
	out.clear();
	
	ServletOutputStream sos = null ;
	try {
		response.setContentType("image/png");
		response.setHeader("cache", "no-cache");
		sos = response.getOutputStream();

		CaptchaService captchaService = new CaptchaService(110, 40); // 值随机,宽度110px,高度40px
		String captcha = EncoderHelper.getChallangeAndWriteImage(captchaService, "png", sos);
		session.setAttribute("captcha", captcha);
		
		sos.flush();
	} catch(Exception exception) {
		exception.printStackTrace();
	} finally {
		if(sos != null) {
			sos.close();
		}
	}
%>